// pages/cat_mse_look/cat_remark.js
const app = getApp()
var that
Page({

  data: {
    cat_id:"",
    remark:"",
    sick:"", //猫咪病史
    title:"",
  },
  onLoad: function (options) {
    that = this;
    console.log(options)
    if (options.type=='remark'){
      this.setData({ remark: options.remark, cat_id: options.id, title:"猫咪备注"});
      wx.setNavigationBarTitle({ title: '修改猫咪备注'})
    }
    if (options.type=='sick') {
      wx.setNavigationBarTitle({ title: '修改猫咪病史' })
      this.setData({ sick: options.sick, cat_id: options.id, title: "猫咪病史"});
    }
  },


  onReady: function () {
  
  },
  onShow: function () {
  
  },
  change:function(e){ 
    if (that.data.title == "猫咪备注") {
    this.setData({ remark: e.detail.value });
    }
    if (that.data.title == "猫咪病史") {
      this.setData({ sick: e.detail.value });
    }
  },
  ok:function(){
    if(that.data.title=="猫咪备注"){
      app.update_cat_msg("remark", that.data.remark, that.data.cat_id);
    }
    if (that.data.title == "猫咪病史") {
      app.update_cat_msg("sick_history", that.data.sick, that.data.cat_id);
    }
    wx.navigateBack({//返回上一级
      delta: 1
    })
  }
})